package com.estar.assistsurvy.activity;

import com.estar.assistsurvy.R;
import com.estar.assistsurvy.entity.PlatformMessage;
import com.google.gson.Gson;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TextView;

public class ReadMessageActivity extends BaseActivity implements OnClickListener{

	private TextView msgContent;
	private LinearLayout returnBack;
	private Intent intent;
	private String content;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_readmessage);
		init();
	}
	
	private void init(){
		msgContent=find(R.id.msgContent);
		Gson gson=new Gson();
		intent=getIntent();
		content=intent.getStringExtra("content");
		PlatformMessage mes=new PlatformMessage();
		mes=gson.fromJson(content, PlatformMessage.class);
		msgContent.setText(mes.getMessage());
		returnBack=find(R.id.returnBack);
		returnBack.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.returnBack:
			finish();
			overridePendingTransition(R.anim.zoom_out, R.anim.zoom_in); 
			break;

		default:
			break;
		}
	}
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		if(keyCode==KeyEvent.KEYCODE_BACK&&event.getAction()==KeyEvent.ACTION_DOWN){
			finish();
			overridePendingTransition(R.anim.zoom_out, R.anim.zoom_in); 
		}
		return super.onKeyDown(keyCode, event);
	}
}
